<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>解析字符串至元素内部</title>
<script>
  function analyze() {
    document.getElementById("sp1").innerText = "<a href='https://www.w3.org/'>W3C</a>";
    document.getElementById("sp2").innerHTML = "<a href='https://www.w3.org/'>W3C</a>";
    document.getElementById("btn").innerText = "新值";
  }
</script>
</head>
<body>
  <button id="btn" type="button" onclick="analyze()">旧值</button><br>
  <span id="sp1"></span><br>
  <span id="sp2"></span>
</body>
</html>